<template>
	<view class="historyOrder">
		<uni-nav-bar
			color="#ffffff"
			background-color="#00aded"
			:statusBar="true"
			title="历史完成运单"
			fixed="true"
			left-icon="left"
			left-text="返回"
			@clickLeft="back"
		></uni-nav-bar>
		<view class="historyOrder_top">
			<dil-search :columnData="options.columnDataList" @onSearch="onSearch" v-if="options.columnDataList.length > 0"></dil-search>
		</view>
		<view class="historyOrder_main">
			<dil-card class="dilCard" @emitEvent="emitEvent" v-bind.sync="options"></dil-card>
		</view>
		<view class="historyOrder_floot"></view>
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
export default {
	data() {
		return {
			options: {
				requestUrl: '/api/v1/tms/getTransOrderList?apiId=575',
				requestQuery: {},
				cardSlotList: [
					{
						label: '作业详情',
						icon: 'bars',
						emitEvent: 'transOrderDetails',
						noPre: '1'
					}
				],
				columnDataList: [],
				totalNum: 0,
				rowDataList: []
			}
		};
	},
	onShow() {
		uni.$emit('onShow', 1);

		this.getOrderSection();
	},
	mounted() {
		this.getOrderSectionDebounce = this.Tool.debounce((data) => {
			this.getOrderSection(data);
		}, 1500);
	},
	methods: {
		back() {
			// #ifdef APP-PLUS
			uni.navigateBack();
			// #endif

			// #ifdef H5
			this.$router.back();
			// #endif
		},
		onSearch(item) {
			this.getOrderSectionDebounce(item);
		},
		//获取运单
		async getOrderSection(data = {}) {
			data.status = '已完成';
			let roleCodes = JSON.parse(uni.getStorageSync('roleCodes'));
			if (roleCodes.includes('siji')) {
				data.jobNumber = uni.getStorageSync('userName').toString();
			}
			this.options.requestQuery = { ...data };
		},
		emitEvent(eventName, cardItem) {
			this[eventName](cardItem);
		},
		transOrderDetails(item) {
			this.updateTransOrderItem(item);
			uni.navigateTo({
				url: '/pages/transOrder/transOrderDetail'
			});
		},
		//vuex
		...mapMutations('common', ['updateTransOrderItem'])
	}
};
</script>

<style lang="scss" scoped>
.historyOrder {
	width: 100vw;
	height: 100%;
	background-color: #f5f5f5;
	&_top {
		background-color: #fff;
	}
	&_main {
	}
	&_floot {
		background-color: #fff;
	}
}
</style>
